﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Medical.DataInterface;
using Medical.Data;
using Medical.Entity;

namespace Medical.Business
{
    /// <summary>
    /// 文章属性值业务操作类
    /// </summary>
    public class BisArticleMetaValue
    {
         /// <summary>
        /// 接口
        /// </summary>
        IArticleMetaValueAccessor accessor;

        /// <summary>
        /// 构造函数
        /// </summary>
        public BisArticleMetaValue()
        {
            //创建接口
            accessor = DataAccess.GetArticleMetaValueAccessor();
        }

        /// <summary>
        /// 获取属性值列表
        /// </summary>
        /// <param name="eType"></param>
        /// <param name="nArticleID"></param>
        /// <returns></returns>
        public DataTable GetList(ArticelTypeEnum eType, int nArticleID)
        {
            return accessor.GetList((int)eType,nArticleID);
        }

          /// <summary>
        /// 获取文章属性值列表
        /// </summary>
        /// <param name="nArticleID"></param>
        /// <returns></returns>
        public DataTable GetList(ArticelTypeEnum eType, string strArticleIDList)
        {
            return accessor.GetList((int)eType, strArticleIDList);
        }

        /// <summary>
        /// 编辑属性值
        /// </summary>
        /// <param name="nArticleID"></param>
        /// <param name="IDList"></param>
        /// <param name="MetaID"></param>
        /// <param name="ValueList"></param>
        /// <returns></returns>
        public bool SetMetaValue(int nArticleID, List<int> IDList, List<int> MetaIDList, List<string> ValueList)
        {
            for (int i = 0; i < IDList.Count; i++)
            {
                ArticleMetaValue Info = new ArticleMetaValue();
                Info.MetaValue = ValueList[i];
                Info.ArticleID = nArticleID;
                Info.ArticleMetaID = MetaIDList[i];
                if (IDList[i] == 0)
                {
                    accessor.Insert(Info);
                }
                else
                {
                    Info.ID = IDList[i];
                    accessor.Update(Info);
                }
            }
            return true;
        }
    }
}
